sessionStorage.OrderCount = sessionStorage.OrderListIds?sessionStorage.OrderListIds.split(',').length:0;
function getlist() {
	$.get('/',{},function(){});
}

setInterval(function(){
	$.get('/Admin/Order/OrderCount',{},function(response){
		if(sessionStorage.OrderCount<response){
			getlist();
			sessionStorage.OrderCount = response;
		}
	});
},'10000');
// getlist();
function getlist() {
	var page = GetQueryString('p');
	var data;
	if(!page){
		data = {
			'p':page,
			'getall':'aj'
		};
	}else{
		data = {
			'getall':'aj'
		};
	}
	$.post('/Admin/Order/OrderListIndex',data,function(response){
		if(response){
			var orderList;
		    $('.tables_order tr').each(function(){
		       orderList = orderList+','+$(this).attr('orderid');
		    });
		    var arrlist;
		    if(orderList){
		        arrlist = orderList.split(',');
		        arrlist.shift();
		    }
	    	for (var i = 0; i < response.length; i++) {
	    		if(arrlist){
	    			if($.inArray(response[i].id,arrlist)<0){
		    			var newtr = '<tr orderid="'+response[i].d['id']+'"><td>'+response[i].d['orderid']+'</td><td>'+response[i].d['create_time']+'</td><td>'+response[i].d['cityid']+'</td><td>'+response[i].d['GWname']+'</td><td>'+response[i].d['GWnum']+'</td><td>'+response[i].d['waynum']+'</td><td>'+response[i].d['waystatus']+'</td><td><a href="/admin/order/OrderDetailsinfo?orderid='+response[i].d['id']+'">审核</a></td></tr>';
		    			$('.tables_order').append(newtr);
		    		}
		    		
	    		}else{
	    			var newtr ='<tr orderid="'+response[i].d['id']+'"><td>'+response[i].d['orderid']+'</td><td>'+response[i].d['create_time']+'</td><td>'+response[i].d['cityid']+'</td><td>'+response[i].d['GWname']+'</td><td>'+response[i].d['GWnum']+'</td><td>'+response[i].d['waynum']+'</td><td>'+response[i].d['waystatus']+'</td><td><a href="/admin/order/OrderDetailsinfo?orderid='+response[i].d['id']+'">审核</a></td></tr>';
		    		$('.tables_order').append(newtr);
	    		}
	    	}
		}
	},'json');
}

function GetQueryString(name)
{
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return null;
}